
package code.codeworld.search.web_search.model.enums;

import java.util.Objects;

/**
 * WebSearch枚举
 *
 * @author freecode
 * @date 2023/03/23 00:20
 **/
public class WebSearchEnum {

    // 模块名称
    public enum ModuleNameEnum {
        KNOW("know", "知识", "know", 1),
        KNOW_PROGRAM("knowProgram", "编程知识", "know?type=编程", 11),
        KNOW_MECHATRONICS("knowMechatronics", "机电知识", "know?type=机电", 12),
        KNOW_MATH("knowMath", "数学知识", "know?type=数学", 13),
        KNOW_PHYSICS("knowPhysics", "物理知识", "know?type=物理", 14),
        KNOW_ASTRONOMY("knowAstronomy", "天文知识", "know?type=天文", 15),
        INFO("info", "信息", "info", 2),
        HOTSPOT("hotspot", "热点", "info?type=热点", 21),
        CREATE("create", "创作", "create", 3),
        SPACE("space", "星域", "space", 4),
        WEB_SAVE("webSave", "导航", "space/webSave", 41),
        BLOG("blog", "博客", "space/blog", 42);

        // 成员变量
        private String code;
        private String name;
        private String href;
        private Integer index;

        // 构造方法
        ModuleNameEnum(String code, String name, String href, Integer index) {
            this.code = code;
            this.name = name;
            this.href = href;
            this.index = index;
        }

        // 普通方法
        public static ModuleNameEnum getEnum(String param) {
            for (ModuleNameEnum e : ModuleNameEnum.values()) {
                if (Objects.equals(e.getCode(), param)) {
                    return e;
                } else if (Objects.equals(String.valueOf(e.getIndex()), param)) {
                    return e;
                }
            }
            return null;
        }

        // get set 方法
        public String getCode() {
            return code;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getHref() {
            return href;
        }

        public void setHref(String href) {
            this.href = href;
        }

        public int getIndex() {
            return index;
        }

        public void setIndex(int index) {
            this.index = index;
        }

    }


}
